<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.mew Set
        let arr = [1, 2, 3, 4, 5, 1, 2, 6, 7, 8]
        let newArr1 = [...new Set(arr)]
        let newArr2=Array.from(new Set(arr))
        console.log(newArr1);
        // 2.filter过滤去重
        let newlist=arr.filter((item,index,arrry)=>{
            return arrry.indexOf(item)==index
        })
        console.log(newlist);
        // 3.json对象去重
        let list={}
        for(let i=0; i < arr.length; i++){
            let key=arr[i];
            if(list[key]){
                list[key]++
            }else{
                list[key]=1
            }
        }
        console.log(list);
        console.log(Object.keys(list));
    </script>
</body>

</html>